package com.baizhi.hospital.controller;

import com.baizhi.hospital.annotation.LogAnnotation;
import com.baizhi.hospital.entity.Department;
import com.baizhi.hospital.service.DepartmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
public class DepartmentController {

	@Autowired
	private DepartmentService departmentService;


	/**
	 *
	 * @param page 接收的页面的页数
	 * @param limit  每页显示的行数
	 * @param name 模糊查询的name
	 * @return 返回此次查询的所有的信息
	 */
	@RequestMapping("/selectDepartment")
	@LogAnnotation(value = "查看所有的科室信息",type = 2)
	public Map selectDepartment(int page, int limit, String name){
		return departmentService.selectDepartment(page,limit,name);
	}


	/**
	 *
	 * @param department 前端页面的数据
	 * @return 添加的详细信息  返回给页面
	 */
	@RequestMapping("/insertDepartment")
	@LogAnnotation(value = "添加科室",type = 2)
	public Map insertDepartment(Department department){
		return departmentService.insertDepartment(department);
	}


	/**
	 *
	 * @param department 接收页面传递的数据 做修改操作
	 * @return 发修改的详细信息
	 */
	@RequestMapping("/updateDepartment")
	@LogAnnotation(value = "修改科室信息",type = 2)
	public Map updateDepartment(Department department){
		return departmentService.updateDepartment(department);
	}


	/**
	 *
	 * @param departmentId  根据页面的参数进行删除
	 * @return 返回详细的信息到页面
	 */
	@RequestMapping("/deleteDepartment")
	@LogAnnotation(value = "删除科室信息",type = 2)
	public Map deleteDepartment(int departmentId){
		return departmentService.deleteDepartment(departmentId);
	}


	/**
	 *
	 * @param array 根据页面的参数进行批量删除
	 * @return 返回删除的信息
	 */
	@RequestMapping("/multiDelete")
	@LogAnnotation(value = "批量删除科室信息",type = 2)
	public Map multiDelete(int[] array){
		return departmentService.multiDelete(array);
	}


	@RequestMapping("/selectRegisterDepartment")
	public List<Department> selectRegisterDepartment(){
		return departmentService.selectRegisterDepartment();
	}

}
